package com.edu.bean;
/*
 * @Author:princess
 * @Date 2023/11/22 11 22 18:52
 *
 */

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;
@Data
public class User {
    private int userId;
    @NotNull(message = "用户名不能为空")
    @Length(min = 6,max = 10,message = "用户名应该在6-10位之间")
    private String username;
    @NotNull(message = "密码不能为空")
    @Length(min = 6,max = 10,message = "密码应该在6-10位之间")
    private String password;
    @NotNull(message = "年龄不能为空")
    @Range(min = 0,max = 150,message = "年龄应该在1-150位之间")
    private int age;
    @Pattern(regexp = "^[男女]$",message = "请输入男或女")
    private String sex;
    @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = {"yyyy/MM/dd","yyyy年MM月dd日"})
    @Past(message = "用户生日应该为一个过去的时间")
    private Date birthday;
    @NumberFormat(style = NumberFormat.Style.CURRENCY,pattern = "￥#,###.##")
    @DecimalMin(value = "1800.00",message = "最低薪资应该符合劳动法")
    private double salary;
    @NumberFormat(style = NumberFormat.Style.PERCENT)
    private double winRate;

    public User(int userId, String username, String password, int age) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.age = age;
    }

    public User() {
    }
}
